#!/usr/bin/python
# coding:utf-8
# auther:DT
# 2017-08-09_03-51-24
import psutil
def cpu_1():
    k_x = psutil.cpu_times_percent()[3]
    return 100-k_x


def disk_two():
    for i in psutil.disk_partitions():
        print("%s分区 使用了 %s%s" % (i[1],psutil.disk_usage(i[1]).percent,'%'))


def mem_1():
    mem_total = psutil.virtual_memory().total
    mem_used = psutil.virtual_memory().used
    return mem_used*100/mem_total


def swap_1():
    swap_total = psutil.swap_memory().total
    swap_used = psutil.swap_memory().used
    return swap_used*100/swap_total

def net_1():
    net_io = psutil.net_io_counters()
    print("发送了多少字节数：%s  接收了多少字节：%s" % (net_io.bytes_sent,net_io.packets_sent))



print(cpu_1())
disk_two()
print("内存使用率：",mem_1())
print("swap使用率：",swap_1())
net_1()
